﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MethodCaching;

namespace SampleLibrary
{
    [EnableMethodCaching]
    public static class StaticSampleClass
    {
        [Cached]
        public static int GetValue(int input)
        {
            return 1;
        }
        
        [Cached]
        public static int GetStringLength(this string targetString)
        {
            return targetString.Length;
        }
    }


    public static class StaticTemplateClass
    {
        private static MethodCache _methodCache;
        
        public static int GetValue(int input)
        {
            return MethodCache.Invoke(DoGetValue, 1);
        }

        private static int DoGetValue(int input)
        {
            return 1;
        }

        private static MethodCache MethodCache
        {
            get
            {
                if (_methodCache == null)
                    _methodCache = new MethodCache();
                return _methodCache;
            }
        }

        public static int GetStringLength(this string targetString)
        {
            return MethodCache.Invoke(DoGetStringLength, targetString);
        }

        private static int DoGetStringLength(string targetString)
        {
            return targetString.Length;
        }
    }
}
